home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
236_01
/
xc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-05
|
26KB
|
883 lines
/*
HEADER: CUG236;
TITLE: Cross Reference Generator;
DATE: 04/05/1987;
DESCRIPTION: "Generic version of programmer's cross-reference
generator originally for BDS.";
VERSION: 2.2;
KEYWORDS: Cross Reference;
FILENAME: XC.C;
SEE-ALSO: CUG126, CUG171;
COMPILERS: vanilla;
AUTHORS: Phillip N. Hisley, W. H. Rauser, W. C. Colley III;
*/
/************************************************************************/
/* 5 APR 1987 Portable C Conversion WCC */
/* - Epson init string changed from hex (\x00) to octal (\000). */
/* - Use () with A?(c=B):(c=C) for portability. If it's an error, */
/* it seems to be a very common one. */
/* - Made use of host compiler's strcmp() and strcpy() as they are */
/* usually written in assembly and run faster. */
/* - Globally replaced "alpha_" with "alp_", "alloc_" with */
/* "allo_", and "tmpchr" with "tmpch" to avoid multiply */
/* defined symbol errors on compilers that only support */
/* @$%&*&?>}\~~@# 6-character names. */
/* - Added abs() macro for compilers that don't have one. */
/* - Used some data initialization to kill off some code. */
/* - Made miscellaneous small tweaks for portability. */
/* - Cleaned out old BDS C stuff to improve readability. */
/* - Cleaned up abortion with use of rf_blk.rf_cnt as a pointer */
/* link to the next rf_blk. This construct will NOT work */
/* in environments like the MSDOS large model where ints */
/* are smaller than pointers! */
/* */
/* 9-26-83 Microsoft C 1.04 Conversion WHR */
/* - \t between line numbers and text to fix indenting problem. */
/* - added option -e for output to Epson in condensed print. */
/* - toupper() and isupper() are macros, not functions. */
/* - eliminate side effect in toupper(*++arg) in main(). */
/* - change alloc() to malloc(). */
/* - add #define NAMES that are not in stdio.h */
/* - MS-C requires () in statement A?(c=B):(c=C) error or not?? */
/* */
/* 4-30-83 Computer Innovations C-86 1.31 Conversion WHR */
/* - #include filename changed to allow a disk drive prefix, D: */
/* - convert if(fprintf(...) == ERROR) lst_err(); to fprintf(..); */
/* - convert if(fopen(...) == ERROR) statements to == NULL. */
/* - C86 requires () in statement A?(c=B):(c=C) error or not?? */
/* - remove getc() == ERROR check in fil_chr(). */
/* - convert file conventions from BDS C to C-86. */
/* - comment out BDS unique statements, mark revised statements. */
/* keep all BDS statements to document conversion effort. */
/* */
/** 4-19-83 BDS C Version file XC.CQ copied from Laurel RCPM WHR */
/************************************************************************/
/* */
/* XC - A 'C' Concordance Utility */
/* */
/* Version 1.0 January, 1982 */
/* */
/* Copyright (c) 1982 by Philip N. Hisley */
/* */
/* Released for non-commercial distribution only */
/* */
/* Abstract: */
/* */
/* 'XC' is a cross-reference utility for 'C' programs. */
/* Its has the ability to handle nested include files */
/* to a depth of 8 levels and properly processes nested */
/* comments as supported by BDS C. Option flags support */
/* the following features: */
/* */
/* - Routing of list output to disk */
/* - Cross-referencing of reserved words */
/* - Processing of nested include files */
/* - Generation of listing only */
/* */
/* Usage: xc <filename> <flag(s)> */
/* */
/* Flags: -i = Enable file inclusion */
/* -l = Generate listing only */
/* -r = Cross-ref reserved words */
/* -o <filename> = Write output to named file */
/* */
/* Please report bugs/fixes/enhancements to: */
/* */
/* Philip N. Hisley */
/* 548H Jamestown Court */
/* Edgewood, Maryland 21040 */
/* (301) 679-4606 */
/* Net Addr: PNH@MIT-AI */
/* */
/***********************************************************/
#include <stdio.h>
/*
* Portability Note: The AZTEC C compilers handle the binary/text file
* dichotomy differently from most other compilers. Uncomment the following
* pair of #defines if you are running AZTEC C:
*/
/*
#define getc(f) agetc(f)
#define putc(c,f) aputc(c,f)
*/
/* Portability Note: 8-bit systems often don't have header files
ctype.h and string.h. If your system doesn't have these,
uncomment the #defines NO_STRING_H and NO_CTYPE_H. WCC */
/*
#define NO_STRING_H
#define NO_CTYPE_H
*/
/* Portability Note: Some older compilers call the function malloc()
by its older name alloc(). If you have one of these older
compilers, uncomment the following #define. WCC */
/*
#define malloc(x) alloc(x)
*/
/* Portability Note: A few compilers don't know the additional type
void. If yours is one of these, uncomment the following #define. */
/* #define void int */
#ifdef NO_CTYPE_H /* WCC */
int isalpha(), isdigit(), isupper(), toupper();
#else
#include <ctype.h> /* WHR */
#endif
#ifdef NO_STRING_H /* WCC */
int strcmp(); char *strcpy();
#else
#include <string.h>
#endif
#ifndef abs /* WCC */
#define abs(x) ((x < 0) ? (-x) : (x))
#endif
/* Portability Note: Some stdio.h files define various of these
constants. Some don't. Therefore, each definition is
compiled only if needed. WCC */
#ifndef NULL /* WCC */
#define NULL 0
#endif
#ifndef FALSE /* WCC */
#define FALSE 0 /* WHR */
#endif
#ifndef TRUE /* WCC */
#define TRUE 1 /* WHR */
#endif
#define MAX_REF 5 /* maximum refs per ref-block */
#define MAX_LEN 20 /* maximum identifier length */
#define MAX_WRD 749 /* maximum number of identifiers */
#define MAX_ALPHA 53 /* maximum alpha chain heads */
#define REFS_PER_LINE 8 /* maximum refs per line */
#define LINES_PER_PAGE 60
#define FF 0x0C /* formfeed */
/* Order of the next two structure declarations reversed to avoid
a forward reference that chokes some compilers. WCC */
struct rf_blk {
int ref_item[MAX_REF];
int ref_cnt;
struct rf_blk *ref_lnk;
} onerf;
struct id_blk {
char id_name[MAX_LEN];
struct id_blk *alp_lnk;
struct rf_blk *top_lnk;
struct rf_blk *lst_lnk;
} oneid, *id_vector[MAX_WRD];
struct alp_hdr { struct id_blk *alp_top;
struct id_blk *alp_lst;
} alp_vector[MAX_ALPHA];
int linum; /* line number */
int edtnum; /* edit line number */
int fil_cnt; /* active file index */
int wrd_cnt; /* token count */
int pagno; /* page number */
int id_cnt; /* number of unique identifiers */
int rhsh_cnt; /* number of conflict hits */
int filevl; /* file level */
int paglin; /* page line counter */
int prt_ref = FALSE;
char act_fil[MAX_LEN];
char lst_fil[MAX_LEN];
char gbl_fil[MAX_LEN];
FILE *l_buffer; /* WHR */
int e_flg = FALSE, i_flg = FALSE, o_flg = FALSE; /* WHR */
int r_flg = FALSE, l_flg = FALSE, debug = FALSE; /* WCC */
char Epson[] = "\033@\017\033Q\204"; /* WCC */
void exit();
/*-------------------------------------------*/
void main(argc,argv)
int argc;
char **argv;
{
char *arg, cc;
void nl(), prnt_tbl(), proc_file(), use_err();
if (argc < 2) use_err();
(void)strcpy(gbl_fil,*++argv);
--argc;
if(gbl_fil[0] == '-')
use_err();
while(--argc != 0)
{ if(*(arg=*++argv) == '-')
/*****{ switch( toupper(*++arg) ) *** side effect in Microsoft C */
{ switch( cc=*++arg, toupper(cc) ) /* Microsoft C */
{ case 'I': i_flg++;
break;
case 'R': r_flg++;
break;
case 'L': l_flg++